#!/usr/bin/env bash

# 声明数组
declare -a a

a[1]=foo
echo ${a[1]}

days=(Sun Mon Tue Wed Thu Fri Sat)
for i in "${days[@]}"; do
	echo $i
done

# 打印下标
for i in "${!days[@]}"; do
	echo $i
done

# 数组元素个数
echo ${#days[@]}
# 数组元素0的长度
echo ${#days[0]}

# 添加元素
days+=("星期一","星期二")
echo "${days[@]}"

a_sorted=($(for i in "${days[@]}"; do echo $i; done | sort))
echo "Sorted array: ${a_sorted[@]}"

declare -A colors
colors["red"]="#ff0000"
colors["green"]="#00ff00"
colors["blue"]="#0000ff"

echo "${colors['blue']}"